// import { message } from "@/utils/message";
import { computed } from "vue";

// 需是hooks写法（函数中有return），避免失去响应性
export function useColumnsNow(
  downloadList: any,
  handleDownloadCallback?: (row: any) => void
) {
  const tableData = computed(() => downloadList.value || []);
  const columns: TableColumnList = [
    {
      label: "资料名称",
      prop: "info_name",
      align: "center"
    },
    {
      label: "下载",
      fixed: "right",
      width: "100px",
      align: "center",
      cellRenderer: ({ row }) => (
        <>
          <img
            src={new URL("@/assets/svg/download.svg", import.meta.url).href}
            style="width: 16px; height: 16px; cursor: pointer;"
            onClick={() => handledownload(row)}
            alt="下载"
          />
        </>
      )
    }
  ];

  const handledownload = (row: any) => {
    // 下载逻辑
    if (handleDownloadCallback) {
      handleDownloadCallback(row);
    } else {
      console.warn("没有设置下载回调函数");
    }
  };

  return {
    columns,
    tableData
  };
}
